﻿CREATE PROCEDURE [dbo].[Member_Select]
	@Id int = NULL,
    @FirstName NVARCHAR(255) = NULL, 
	@LastName NVARCHAR(255) = NULL,
	@Email NVARCHAR(255) = NULL, 
    @Password NVARCHAR(255) = NULL, 
    @UserID NVARCHAR(255) = NULL,  
    @Isdoctor bit = NULL,
	@IsActive bit = NULL,
	@IsReset UNIQUEIDENTIFIER = NULL 

AS

	SELECT *
	FROM[Members]
	WHERE 
	(
		( @Id IS NULL OR Id = @Id ) AND 
		( @FirstName IS NULL OR FirstName LIKE @FirstName + '%' ) and
		( @LastName IS NULL OR LastName	LIKE @LastName + '%' ) and
		( @Email IS NULL OR Email	LIKE @Email + '%' ) and
		( @Password IS NULL OR [Password]	LIKE @Password + '%' ) and
		( @UserID IS NULL OR UserID like @UserID + '%') and
		( @Isdoctor IS NULL OR IsDoctor = @Isdoctor ) and
		( @IsActive IS NULL OR IsActive = @IsActive) and
		( @IsReset is null or IsReset = @IsReset)
	)